blob: 54f6234736f240b43c67355eb86bc85a00fcfa56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
---
import { getCollection } from "astro:content";
import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
import Note from "@/components/note/Note.astro";
import PageLayout from "@/layouts/Base.astro";
// if you're using an adaptor in SSR mode, getStaticPaths wont work -> https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr
export const getStaticPaths = (async () => {
// Get both local notes and Pleroma posts
const [allNotes, allMicro] = await Promise.all([
getCollection("note"),
getCollection("micro").catch(() => []), // Fallback to empty array if micro collection fails
]);
const allPosts = [...allNotes, ...allMicro];
return allPosts.map((post) => ({
params: { slug: post.id },
props: { note: post }, // Keep 'note' name for compatibility with existing component
}));
}) satisfies GetStaticPaths;
export type Props = InferGetStaticPropsType<typeof getStaticPaths>;
const { note } = Astro.props;
const meta = {
description:
note.data.description ||
`Read about my note posted on: ${note.data.publishDate.toLocaleDateString()}`,
title: note.data.title,
};
---
<PageLayout meta={meta}>
<Note as="h1" note={note} />
</PageLayout>
|